/**
 * Copyright &copy; 2016-2017 <a href="https://www.lczyfz.com">联创智云</a> All rights reserved.
 */
package com.lczyfz.campusinfo.modules.user.web;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.lczyfz.campusinfo.common.web.BaseController;
import com.lczyfz.campusinfo.modules.sys.entity.User;
import com.lczyfz.campusinfo.modules.user.service.CampusinfoUserService;
import com.lczyfz.campusinfo.modules.user.utils.ServerResponse;

/**
 * 用户信息Controller
 * @author 陈维乾
 * @version 2018-03-31
 */
@Controller
@RequestMapping(value = "${frontPath}/campusinfo/user")
public class CampusinfoUserApiController extends BaseController {

	@Autowired
	private CampusinfoUserService campusinfoUserService;
	
//	//登录用户
//	@ResponseBody
//	@RequestMapping(value = "login",method = RequestMethod.POST)
//	public ServerResponse<String> login(HttpServletRequest request ){
//
//		return campusinfoUserService.login(request);
//	}

	//用户登录判断是否需要验证码
	@ResponseBody
	@RequestMapping(value = "is_ValidatjeesiteLogin",method = RequestMethod.POST)
	public ServerResponse<String> isValidatjeesiteLogin(String loginName){
		return campusinfoUserService.isValidatjeesiteLogin(loginName);
	}

	//注册用户
	@ResponseBody
	@RequestMapping(value = "register",method = RequestMethod.POST)
	public ServerResponse<String> register(User user ,String verifyNum,HttpServletRequest request){

		return campusinfoUserService.register(user,verifyNum,request);
	}

	//短信验证
	@ResponseBody
	@RequestMapping(value = "verify_by_sendmsg",method = RequestMethod.POST)
	public ServerResponse<String> verifyBySendMsg(String mobile,HttpServletRequest request){

		return campusinfoUserService.verifyBySendMsg(mobile,request);
	}
	//判读用户名是否存在
	@ResponseBody
	@RequestMapping(value = "is_userName",method = RequestMethod.POST)
	public ServerResponse<String> isUserName(String userName){

		return campusinfoUserService.isUserName(userName);
	}
	//判读邮箱是否存在
	@ResponseBody
	@RequestMapping(value = "is_email",method = RequestMethod.POST)
	public ServerResponse<String> isEmail(String email){

		return campusinfoUserService.isEmail(email);
	}
	
	//判断是否已登录
	@ResponseBody
	@RequestMapping(value = "has_user",method = RequestMethod.POST)
	public ServerResponse<String> hasUser(){
		logger.debug("判断用户是否登陆");
		return campusinfoUserService.hasUser();
	}

	//忘记密码
	@ResponseBody
	@RequestMapping(value = "forget_reset_password",method = RequestMethod.POST)
	public ServerResponse<String> forgetRestPassword(String mobile,String verifyNum,String passwordNew,HttpServletRequest request){
		return campusinfoUserService.forgetResetPassword(mobile,verifyNum,passwordNew,request);
	}

	//获取当前用户信息
	@ResponseBody
	@RequestMapping(value = "get_user_info",method = RequestMethod.POST)
	public ServerResponse<User> getUserInfo(){

		return campusinfoUserService.getUserInfo();
	}

	//登录状态重设密码
	@ResponseBody
	@RequestMapping(value = "reset_password",method = RequestMethod.POST)
	public ServerResponse<String> resetPassword(String passwordOld,String passwordNew){

		return campusinfoUserService.resetPassword(passwordOld,passwordNew);
	}
	//更新当前用户个人信息
	@ResponseBody
	@RequestMapping(value = "update_information",method = RequestMethod.POST)
	public ServerResponse<User> updateInformation(String msg, String type, @RequestParam(required = false ,value = "")String verifyNum){
		return campusinfoUserService.updateInformation(msg,type,verifyNum);
	}
	//判断是否实名认证（姓名，学校，学号，手机号码）
	@ResponseBody
	@RequestMapping(value = "is_verify_user",method = RequestMethod.POST)
	public ServerResponse<String> isVerifyUser(){
		return campusinfoUserService.isVerifyUser();
	}
	//注册时判断手机是否存在
	@ResponseBody
	@RequestMapping(value = "has_mobile",method = RequestMethod.POST)
	public ServerResponse<String> hasMobile(String mobile){
		return campusinfoUserService.hasMobile(mobile);
	}
	//修改个人信息的手机时 判断手机号是否与原来相同 和判断是否存在
	@ResponseBody
	@RequestMapping(value = "check_mobile",method = RequestMethod.POST)
	public ServerResponse<String>  checkMobile(String mobile){
		return campusinfoUserService.checkMobileUpdate(mobile);
	}

}